<?php
namespace App\Model;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/29
 * Time: 18:12
 */
use App\Model\Backstage\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Auth;




class Base extends Model{

    public $branch_id;
    public $system_id;
    public $store_id;
    public $uid;
    public $authories;
    public $name;
    public function __construct()
    {
        $branch_info = Auth::user();
        if(empty($branch_info)){
            $apptoken = $_REQUEST['apptoken'];
            $data = explode(',', Redis::get($apptoken));
            $this->branch_id  = $data[0];    //公司ID
            $this->system_id = $data[1];   //系统管理组部门ID
            $this->store_id       = $data[2];   //部门id
            $this->uid      = $data[3];   //员工ID
            $this->name      = $data[4];   //员工名称
            $this->authories = Redis::get($apptoken.$data[3]);    //员工拥有的权限
//            dd($this->branch_id.'+++'.$this->system_id.'++++'.$this->store_id.'+++'.$this->uid.'+++'.$this->authories);
        } else {
            $this->branch_id = $branch_info['u_b_id'];  //公司ID
            $this->store_id  = $branch_info['u_d_id'];   //部门id
            $this->uid       = $branch_info['u_id'];    //员工ID
            $this->authories = $branch_info['authories'];    //员工拥有的权限
            $this->name      = $branch_info['u_username'];    //员工名字
        }
    }
}